package com.transfiguro.core;

import com.transfiguro.datamodel.csmodels.CSClassModel;
import com.transfiguro.datamodel.csmodels.CSMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class provides methods for analyzing different data models
 */
public class Analyzer {
    private final Logger logger = LoggerFactory.getLogger(Analyzer.class);

    /**
     * Takes a {@link CSClassModel} and returns a CSV string with
     * conversion times for the class and the methods in the class
     *
     * @param classModel The <code>CSClassModel</code> that has to be analyzed
     * @return A CSV string containing the class and method conversion times
     */
    public String getStatistics(final CSClassModel classModel) {
        StringBuilder result = new StringBuilder();

        result.append(classModel.getClassName()).append(", ").append(classModel.getConversionTime())
                .append('s').append('\n');
        for (final CSMethod method : classModel.getMethods()) {
            result.append(method.getMethodName()).append(", ")
                    .append(method.getConversionTime()).append('s').append('\n');
        }

        return result.toString();
    }
}
